package com.kele.controller;

import com.kele.service.LoginService;
import com.kele.service.impl.LoginServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author chunhui.li
 * @date 2021/10/18 15:01
 * @Description
 * @ClassName TokenLoginController
 */
@RestController
@RequestMapping("/login")
public class TokenLoginController {

    @Autowired
    private LoginServiceImpl loginService;

    @GetMapping({"/",""})
    public String login(String username,String password){
        return loginService.login(username, password);
    }

    @GetMapping("/logout")
    public String logout(HttpServletRequest request){
        System.out.println(request.getHeader("token"));
        return loginService.logout(request);
    }
}
